 As in previous examples, we include the header file declaring the required user functions.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Then, we define the initial condition.

{\bfseries  The {\ttfamily uinit} function }

The initial condition for the vector field is defined for this example problem to introduce small perturbation as following.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


{\bfseries  The {\ttfamily define\-Parameters} function }

Instead of applying Dirichlet boundary conditions, in this example, we apply periodic conditions as\-:


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We also define the mesh as in other examples by setting the number of elements in each direction.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We also define the dimensions of the domain, e.\-g. a unit cube.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We specify the number of vector solution by adding the name of the field to a vector.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We also specify the polynomial order of the basis splines and the global continuity.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We redirect the desired user function pointer {\ttfamily uinit} function that we defined above.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Finally, we define various (9) material parameters that describe the gradient elasticity.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


{\bfseries  The {\ttfamily residual} function }

The residual function for the gradient elasticity with periodic conditions is used in this example.

We first declare {\ttfamily \char`\"{}eval\-\_\-residual\char`\"{}} non-\/member function to be used in the member function, {\ttfamily \char`\"{}residual\char`\"{}}.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


The definition of the {\ttfamily eval\-\_\-residual} function is postponed until the end of the file as it is lengthy.

It is convenient to unfold \char`\"{}u.\-val\char`\"{}, \char`\"{}u.\-grad\char`\"{}, and \char`\"{}u.\-hess\char`\"{} and put them into a single array, ui\mbox{[}\mbox{]}.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We do the same for previous solutions represented by \char`\"{}.\-val\-P\char`\"{}, \char`\"{}.\-grad\-P\char`\"{}, and \char`\"{}.\-hess\-P\char`\"{} as well as for the test functions \char`\"{}w2\char`\"{} and produce arrays, u0\mbox{[}\mbox{]} and w\mbox{[}\mbox{]}, respectively.

We then evaluate the residual vector at a given quadrature point (residual\mbox{[}\mbox{]}) using the declared function \char`\"{}eval\-\_\-residual\char`\"{}.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Finally, we multiply residual\mbox{[}\mbox{]} by test functions and form the integrand of the weak form at the given quadrature point.


\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


\section*{The complete code }

 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
 